Real Time Status Bar Clock

This script automatically sets the status bar text to the current time. It refreshes the time every half-second. (Press the button below to toggle the clock. The clock is "on" by default.)


Discussion

This script sets a timeout in the BODY tag to automatically load the setMessage() function. In this function, the timeout is reloaded. Timeout evaluates expressions after a set number of milliseconds ellapse. The variable JSCActive keeps track of whether or not the real-time clock is active. Please note that some early versions of Netscape Navigator 2.0 do not produce the correct time.

The BODY tag

<BODY bgcolor="ffffff" link="0000ff" vlink="770077"
onload="JSCTimeOutID = window.setTimeout('setMessage()',500);">

Renewing the TimeOut in setMessage()

JSCTimeOutID = window.setTimeout('setMessage()',1000);

Stopping and Restarting the clock with the button

<INPUT TYPE="button" VALUE="TOGGLE THE CLOCK"
onClick="toggle()">

Stopping the clock in setMessage()

clearTimeout(JSCTimeOutID)
Copyright ©1998 by Charles River Media, All Rights Reserved